# _*_ coding:utf-8 _*_
"""
@author:lx
@file: minmaxloc
@contact: lixiang-929@outlook.com
@time: 2019/03/24
"""
import cv2
import numpy as np
import matplotlib.pyplot as plt

# image = cv2.imread('.\\yellow\\1_yellow_image.jpg',0)
image = cv2.imread('red_thr1.jpg',0)
imin,imax = cv2.minMaxLoc(image)[:2]
thr = int((imin + imax) / 2)

ret,THR = cv2.threshold(image,thr,255,cv2.THRESH_BINARY)
print(ret)
# plt.subplot(141), plt.imshow(image, "gray")
# plt.subplot(142), plt.hist(image.ravel(), 256)
# plt.subplot(143), plt.imshow(THR, "gray")
cv2.imwrite('red_thr1.jpg', THR)
# ret1, th1 = cv2.threshold(THR, thr, 255, cv2.THRESH_OTSU)
# plt.subplot(144), plt.imshow(th1, "gray")
# print(ret1)
print('imin,imax=',imin,imax)
plt.show()
